<template>
    <div>
   <h1>新增康复理疗页面</h1>
    </div>

     <table class="table">
           <tbody>
              <tr>
                   <td>项目名称</td>
                    <td>
                          <input type="text" v-model="data.sosConeNmae">
                    </td>
              </tr>

                  <tr>
                   <td>服务时长</td>
                    <td>
                          <input type="text" v-model="data.sosConeSC">
                    </td>
              </tr>

                  <tr>
                   <td>服务人数</td>
                    <td>
                          <input type="text" v-model="data.sosConeNum">
                    </td>
              </tr>

                  <tr>
                   <td>佣金</td>
                    <td>
                          <input type="text" v-model="data.price">
                    </td>
              </tr>

                  <tr>
                   <td>项目说明</td>
                    <td>
                        <textarea v-model="data.sosConeType"></textarea>
                    </td>
              </tr>

                  <tr>
                   <td>分类名称</td>
                    <td>
                        <select v-model="data.sosConeTypeId">
                             <option value="0">==请选择分类==</option>
                             <option v-for="a in obj" :value="a.sosConeTypeId">{{a.sosConeName}}</option>
                        </select>
                    </td>
              </tr>

                  <tr>
                   <td></td>
                    <td>
                         <input type="button" value="新增" class="btn btn-info" @click="adds"> 
                    </td>
              </tr>

           </tbody>
     </table>
</template>

<script setup lang="ts">
  import type { RefSymbol } from '@vue/reactivity';
import axios from 'axios';
   import {ref,onMounted} from 'vue';
    import {useRouter} from 'vue-router';
     const router=useRouter();

onMounted(()=>{
    sosConeTypes();
})
 
  const obj=ref({
   "sosConeTypeId": 0,
    "sosConeName": ""
  })
   const sosConeTypes=()=>{
       axios.get("https://localhost:7048/api/SosConeType/sosConeTypes").then(res=>{
           obj.value=res.data;

       })
   }




    const data=ref({
  "sosConeId": 0,
  "sosConeNmae": "",
  "code": "string",
  "sosConeSC": 0,
  "sosConeNum": 0,
  "price": 0,
  "sosConeType": "",
  "sosConeTypeId": 0,
  "state": true,
  "isDelete": true
    })

    const adds=()=>{

         if(data.value.sosConeNmae==""){
           alert("项目名称不能为空");
            return;

         }

     if(data.value.sosConeSC==0){
           alert("服务人数不能为空");
            return;            
         }

     

        


     if(data.value.price==0){
           alert("佣金不能为空");
            return;
            
         }

               if(data.value.sosConeType==""){
           alert("项目说明不能为空");
            return;
            
         }

                 if(data.value.sosConeTypeId==0){
           alert("分类名称不能为空");
            return;
            
         }


          axios.post("https://localhost:7048/api/SosCone/AddAnync",data.value).then(res=>{
              if(res.data>0){
                 alert("新增成功");
                  return;
              }else{
                     alert("新增失败");
              }
          })
    }
     
</script>

<style scoped>

</style> 